VERSION 5.00
Begin VB.Form ComputerLocationForm 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   BorderStyle     =   0  'None
   ClientHeight    =   9000
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   12000
   LinkTopic       =   "Form1"
   ScaleHeight     =   9000
   ScaleWidth      =   12000
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   WindowState     =   2  'Maximized
   Begin VCT.TouchScreenListBox ComputerLocationList 
      Height          =   8415
      Left            =   240
      TabIndex        =   1
      Top             =   360
      Width           =   9015
      _ExtentX        =   15901
      _ExtentY        =   14843
   End
   Begin VB.CommandButton Cancel_Button 
      BackColor       =   &H008080FF&
      Caption         =   "Cancel"
      BeginProperty Font 
         Name            =   "Arial Narrow"
         Size            =   20.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   735
      Left            =   9600
      Style           =   1  'Graphical
      TabIndex        =   0
      Top             =   360
      Width           =   2055
   End
End
Attribute VB_Name = "ComputerLocationForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Cancel_Button_Click()
   LoginForm.Show
   Unload Me
End Sub

Private Sub Form_Load()
   BuildComputerLocationList
End Sub

Private Sub ComputerLocationList_click()
   Dim RecordFound As Boolean
   
   ComputerLocationList.Enabled = False
   Cancel_Button.Enabled = False
   
   CnUser.Open ConnectString
   Cmd.CommandText = "Select WSLocation " _
                      & "From ComputerLocation " _
                      & "Where WSName = '" & Machine_Id & "'"
   Cmd.CommandType = adCmdText
   Cmd.ActiveConnection = CnUser
   RsUser.Open Cmd, , adOpenStatic
   If RsUser.EOF = False Then 'a record was found for that computer
      RecordFound = True
   Else
      RecordFound = False
   End If
   RsUser.Close
   CnUser.Close
   
   If RecordFound = True Then 'update the existing location
      CnUser.Open ConnectString
      Cmd.CommandText = "Update ComputerLocation " _
                      & "SET WSLocation = '" & ComputerLocationList.Text _
                      & "' WHERE WSName = '" & Machine_Id & "'"
      Cmd.CommandType = adCmdText
      Cmd.ActiveConnection = CnUser
      Cmd.Execute
      CnUser.Close
   
   Else 'add a new record
      CnUser.Open ConnectString
      Cmd.CommandText = "INSERT ComputerLocation VALUES ('" & Machine_Id & "','" & ComputerLocationList.Text & "')"
      Cmd.CommandType = adCmdText
      Cmd.ActiveConnection = CnUser
      Cmd.Execute
      CnUser.Close
   
   End If

   LoginForm.Show
   Unload Me
   
End Sub

Private Sub BuildComputerLocationList()
   ComputerLocationList.DeleteList
   ComputerLocationList.AddItem "01 - MACRO Blantyre"
   ComputerLocationList.AddItem "02 - MACRO Lilongwe"
   ComputerLocationList.AddItem "03 - MACRO Mzuzu"
   ComputerLocationList.AddItem "04 - MACRO Zomba"
   ComputerLocationList.AddItem "05 - MACRO Kasungu"
   ComputerLocationList.AddItem "06 - MACRO Karonga"
   ComputerLocationList.AddItem "11 - Lighthouse Centre"
   ComputerLocationList.AddItem "12 - Lighthouse Bottom Hospital"
   ComputerLocationList.AddItem "13 - Lighthouse KCH Medical Ward"
   ComputerLocationList.AddItem "14 - Lighthouse KCH Paediatric Ward"
   ComputerLocationList.AddItem "15 - Lighthouse Area 18 Health Centre"
   ComputerLocationList.AddItem "16 - Lighthouse Chinsapo Health Centre"
End Sub
